package com.e3.basdoc.measure.client;

import java.util.List;

import com.e3.basdoc.measure.model.MeasureUnitModel;
import com.e3.template.tgf.MyGFUI;
import com.e3.template.tgf.TGFEditorDialog;
import com.e3.template.tgf.TGFGridPanel;
import com.e3.template.tgf.TGFQueryDialog;
import com.e3.template.tgf.TGFSimpleFormPanel;
import com.e3.template.tgf.TGFStateMachine;
import com.e3.web.core.client.GXTHelper;
import com.e3.web.widget.client.BaseAction;
import com.google.gwt.user.client.rpc.AsyncCallback;

public class MeasureUnitUI extends MyGFUI<MeasureUnitModel> {
	
	private MeasureUnitRPCServiceAsync service = MeasureUnitRPCService.Util.getInstance();

	@Override
	protected TGFSimpleFormPanel<MeasureUnitModel> createFormPanel() {
		return new MeasureUnitFormPanel();
	}

	@Override
	protected TGFGridPanel<MeasureUnitModel> createGridPanel() {
		return new MeasureUnitGridPanel();
	}

	@Override
	protected TGFQueryDialog<MeasureUnitModel> createQueryDialog() {
		return new MeasureUnitQueryDialog();
	}

	@Override
	protected TGFEditorDialog<MeasureUnitModel> createEditorDialog() {
		return new MeasureUnitEditorDialog();
	}

	@Override
	protected void executeDeleteService(final List<MeasureUnitModel> models,AsyncCallback<Void> callback) {
		service.deleteMeasureUnits(models,callback);
	}

	@Override
	protected String getCurrentLocalName() {
		return MeasureUnitMessages.INSTANCE.local_name();
	}

	@Override
	protected MeasureUnitModel createModelInstance() {
		return new MeasureUnitModel();
	}

	@Override
	protected BaseAction[] getToolButtonActions() {
		if(GXTHelper.isSuperAdmin()){
			return super.getToolButtonActions();
		}
		return new BaseAction[]{TGFStateMachine.QUERY_ACTION,TGFStateMachine.NEW_ACTION,TGFStateMachine.MODIFY_ACTION};
	}
}
